//
//  LCTabBarController.m
//  test
//
//  Created by macpro on 16/3/19.
//  Copyright © 2016年 wangdao. All rights reserved.
//

#import "LCTabBarController.h"
#import "CountViewController.h"
#import "EditorViewController.h"
#import "TongLanViewController.h"
#import "MeViewController.h"
#import "MaterialViewController.h"
#import "UITabBar+NumberOfTabbar.h"
@interface LCTabBarController ()

@end

@implementation LCTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
    //添加各个控制器
    [self addAllChilds];
}

#pragma mark 添加各个子控制器
- (void)addAllChilds
{
    
    
    
    
    
    
    //
    EditorViewController *gwVc =[[EditorViewController alloc]init];
    [self addOneController:gwVc image:[UIImage imageNamed:@"tabbar_item_thing"] selected:nil title:@"编辑"];
    
    //
    TongLanViewController *MVc =[[TongLanViewController alloc]init];
    [self addOneController:MVc image:[UIImage imageNamed:@"tabbar_item_reading"] selected:nil title:@"素材"];
    
    CountViewController * glVc =[[CountViewController alloc]init];
    [self addOneController:glVc image:[UIImage imageNamed:@"tabbar_item_home"] selected:nil title:@"统计"];
    //
    MeViewController *discoverVc =[[MeViewController alloc]init];
    [self addOneController:discoverVc image:[UIImage imageNamed:@"tabbar_item_person"] selected:nil title:@"我的"];
//    //点击消息进来的推送
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushSomething) name:@"backicon" object:nil];
   

}
#pragma mark 创建子控制器
- (void)addOneController:(UIViewController *)childVc image:(UIImage *)image selected:(UIImage *)selected title:(NSString *)title
{
    //设置子控制器的标题
    childVc.title = title;
    //设置子控制器默认图片
    childVc.tabBarItem.image =image;
    UIImage *selectedImage = nil;
    selectedImage = [selected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //设置子控制器被选中时的图片
    childVc.tabBarItem.selectedImage = selected;
    
    //嵌入导航控制器
    UINavigationController *nav =[[UINavigationController alloc]initWithRootViewController:childVc];
    //将导航控制器加入到tab
    [self addChildViewController:nav];
    
    self.tabBar.tintColor = UIColorFromRGB(MYColor);
    
}
//-(void)pushSomething{
//    [self.tabBarController.tabBar hideBadgeOnItemIndex:3];
//    
//    MaterialViewController *mater = [[MaterialViewController alloc]init];
//    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:mater];
//    [self presentViewController:nav animated:YES completion:^{
//        
//    }];
//    
//}


@end
